﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public partial class PeerReviewBeenVoter
    {

        /// <summary>
        /// 
        /// </summary>
        private readonly DAL.PeerReviewBeenVoter dal = new DAL.PeerReviewBeenVoter();


        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public DataTable GetAllList(string entityNo, string beenVoterClsCd)
        {
            return dal.GetAll(entityNo, beenVoterClsCd).Tables[0];        
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public List<Model.PeerReviewBeenVoter> GetAllListByClsCd(string entityNo, string beenVoterClsCd)
        {
            DataSet ds = dal.GetAllByClsCd(entityNo, beenVoterClsCd);
            return DataTableToListVoterCls(ds.Tables[0]);

        }

                /// <summary>
        /// 
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public List<Model.PeerReviewBeenVoter> GetAllList(string strwhere)
        {
            DataSet ds = dal.GetAllList(strwhere);
            return DataTableToListVoterCls(ds.Tables[0]);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="empNo"></param>
        /// <returns></returns>
        public string GetDeptNoByEmpNo(string empNo)
        {
            return dal.GetDeptNoByEmpNo(empNo);
        }
        /// <summary>
        /// 增加数据
        /// </summary>
        /// <param name="model"></param>
        public void Add(List<Model.PeerReviewBeenVoter> peerReviewBeenVotorModelList, string beenVoterClsCd, decimal peerReviewID)
        {
            dal.Add(peerReviewBeenVotorModelList, beenVoterClsCd, peerReviewID);
        }
        /// <summary>
        ///  获得数据列表
        /// <summary>
        /// <creator>chenly</creator>
        /// <date>2013-10-18</date>
        /// </summary>
        /// <param name="dt">一张DataTable</param>
        /// <returns>返回Model</returns>
        public List<Model.PeerReviewBeenVoter> DataTableToListVoterCls(DataTable dt)
        {
            List<Model.PeerReviewBeenVoter> modelList = new List<Model.PeerReviewBeenVoter>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.PeerReviewBeenVoter model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.PeerReviewBeenVoter();
                    if (dt.Rows[n]["FEntityNo"] != null)
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }
                    if (dt.Rows[n]["FBeenVoterEmplNo"] != null)
                    {
                        model.FBeenVoterEmplNo = dt.Rows[n]["FBeenVoterEmplNo"].ToString();
                    }
                    if (dt.Rows[n]["FBeenVoterClsCd"] != null)
                    {
                        model.FBeenVoterClsCd = dt.Rows[n]["FBeenVoterClsCd"].ToString();
                    }
                    if (dt.Rows[n]["FPeerReviewID"] != null && dt.Rows[n]["FPeerReviewID"].ToString() != "")
                    {
                        model.FPeerReviewID = decimal.Parse(dt.Rows[n]["FPeerReviewID"].ToString());
                    }
                    if (dt.Rows[n]["FBeenVoterDeptNo"] != null)
                    {
                        model.FBeenVoterDeptNo = dt.Rows[n]["FBeenVoterDeptNo"].ToString();
                    }
                    if (dt.Rows[n]["FEmpName"] != null)
                    {
                        model.FEmpName = dt.Rows[n]["FEmpName"].ToString();
                    }
                    if (dt.Rows[n]["deptName"] != null)
                    {
                        model.deptName = dt.Rows[n]["deptName"].ToString();
                    }

                    modelList.Add(model);
                }
            }
            return modelList;
        }

    }
}
